<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath %>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>修改密码</title>
		<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="css/login.css" />
	</head>
	<body class="admin-main">
		<div style="  margin: 10em auto;width: 76em;">
		<fieldset class="layui-elem-field " style="margin-top: 20px;  padding: 3em;">
				  <legend>密码修改</legend>
			<form class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">原密码</label>
					<div class="layui-input-block">
						<input type="password" name="opwd" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">新密碼</label>
					<div class="layui-input-inline">
						<input type="password" name="npwd" required lay-verify="required|_password" placeholder="请输入密码" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">6-20位字母数字组合</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
					<button lay-filter="edit" class="layui-btn" lay-submit>提交</button>
					</div>
				</div>
			</form>
			</fieldset>
		</div>
</body>
<script type="text/javascript" src="plugins/layui/layui.js"></script>
<script>

layui.use(['form','layer'], function() {
	var $ = layui.jquery,
	layer = layui.layer, //获取当前窗口的layer对象
	form = layui.form();

	form.render();
			
	form.on('submit(edit)', function(data) {
				$.ajax({
					type: 'post',
					url:  'user/editpsd',
					data: data.field,
					dataType: 'json',
					success: function(result, status, xhr) {
						if(result.flag){
								//修改成功跳转
							window.location.href = "logout";
							}
						layer.msg(result.msg);
						}
				});
				
			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。									
	});
});

</script>
</html>